package com.sz.common.pay.pingan.entity.common;

import com.sz.common.pay.common.DateGenerator;
import com.sz.common.pay.pingan.constant.ResponseCode;
import lombok.Data;

/**
 * Function: 通用响应头数据 <br>
 * @author: siqishangshu <br>
 * @date: 2017-10-30 17:59:00
 * <p>
 * API参数输入
 * API回参读取
 * <p>
 * private String TranDateTime;//交易时间
 * private String ThirdLogNo;//交易流水号
 * String rspCode=(String)retKeyDict.get("RspCode");//银行返回的应答码
 * String rspMsg=(String)retKeyDict.get("RspMsg");//银行返回的应答描述号
 */
@Data
public class CommonHeadResponse {
    private String TranFunc = "0";
    private String TranDateTime;
    private String ThirdLogNo;
    private String RspCode;
    private String RspMsg;

    public CommonHeadResponse() {
        this.TranDateTime = DateGenerator.getyyyyMMddHHmmss();
    }

    public CommonHeadResponse(String thirdLogNo, ResponseCode responseCode) {
        this.TranDateTime = DateGenerator.getyyyyMMddHHmmss();
        this.ThirdLogNo = thirdLogNo;
        this.RspCode = responseCode.getCode();
        this.RspMsg = responseCode.getMessage();
    }

    public CommonHeadResponse(String thirdLogNo) {
            this.TranDateTime = DateGenerator.getyyyyMMddHHmmss();
            this.ThirdLogNo = thirdLogNo;

    }
    public void failed(CommonHeadResponse errorMessage){
        this.RspCode = errorMessage.getRspCode();
        this.RspMsg = errorMessage.getRspMsg();
    }
    public void failed(){
        this.RspCode = ResponseCode.FAILED.getCode();
        this.RspMsg = ResponseCode.FAILED.getMessage();
    }
    public void succeed() {
        this.RspCode = ResponseCode.SUCCEED.getCode();
        this.RspMsg = ResponseCode.SUCCEED.getMessage();
    }
}
